package com.example.spinning.service;

import com.example.spinning.bean.Category;
import com.example.spinning.bean.Organ;
import com.example.spinning.mapper.CategoryMapper;
import com.example.spinning.mapper.OrganMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;
import java.util.List;

/**
 * 机构管理
 */
@Service
@Transactional
public class OrganService {
    @Autowired
    OrganMapper organMapper;

    public List<Organ> getSpecificOrgans(int page,int count,Organ organ){
        int start = (page-1)*count;
        return organMapper.getSpecificOrgans(start,count,organ);
    }

    public List<Organ> getAllOrgans() {
        return organMapper.getAllOrgans();
    }

    public boolean deleteOrganByIds(String ids) {
        String[] split = ids.split(",");
        int result = organMapper.deleteOrganByIds(split);
        return result == split.length;
    }

    public int updateOrganById(Organ organ) {
        return organMapper.updateOrganById(organ);
    }

    public int addOrgan(Organ organ) {
        return organMapper.addOrgan(organ);
    }

    //由名字找到行数
    public int getOrganCountByCondition(Organ organ) {
        return organMapper.getOrganCountByCondition(organ);
    }
}
